<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="3" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button @click="filter" icon="filter" style="margin-right: 8px; background: #f47920; color: white"
                >筛选</a-button
              >
            </span>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button @click="searchReset" icon="delete" style="margin-right: 8px; background: #f47920; color: white"
                >清除</a-button
              >
              <a-button type="primary" @click="searchQuery" icon="search">搜索</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">添加</a-button>

      <a-button @click="batchDel" type="primary" icon="delete">删除</a-button>
      <a-button @click="searchReset" type="primary" icon="reload">刷新</a-button>

      <a-button @click="recycle" type="danger" icon="delete">回收站</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="showDataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ fixed: true, selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无此图片</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt="图片不存在"
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无此文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">查看</a>
          <a-divider type="vertical" />
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>

    <veJwBzr-modal ref="modalForm" @ok="modalFormOk"></veJwBzr-modal>
    <ve-jw-bzr-recycle-bin ref="recycle" @click="recycleFormOk"></ve-jw-bzr-recycle-bin>
    <ve-jw-bzr-filter ref="filter" @ok="filterFormOk"></ve-jw-bzr-filter>
  </a-card>
</template>

<script>
import { EduListMixin } from '@/mixins/KwglMixin'
import VeJwBzrModal from './modules/VeJwBzrModal'
import VeJwBzrRecycleBin from './modules/VeJwBzrRecycleBin.vue'
import VeJwBzrFilter from './modules/VeJwBzrFilter.vue'

export default {
  name: 'VeJwBzrList',
  mixins: [EduListMixin],
  components: {
    VeJwBzrModal,
    VeJwBzrRecycleBin,
    VeJwBzrFilter,
  },
  data() {
    return {
      description: 've_jw_bzr管理页面',
      // 表头
      columns: [
        {
          title: '班级',
          align: 'center',
          dataIndex: 'bjidName',
        },
        {
          title: '班主任',
          align: 'center',
          dataIndex: 'teacheridName',
        },
        {
          title: '学期ID',
          align: 'center',
          dataIndex: 'semidName',
        },
        {
          title: '创建日期',
          align: 'center',
          dataIndex: 'createTime',
        },

        {
          title: '最后修改时间',
          align: 'center',
          dataIndex: 'updateTime',
        },
        {
          title: '创建人',
          align: 'center',
          dataIndex: 'createBy',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/jxgz/veJwBzr/list',
        delete: '/jxgz/veJwBzr/delete',
        deleteBatch: '/jxgz/veJwBzr/deleteBatch',
        exportXlsUrl: '/jxgz/veJwBzr/exportXls',
        importExcelUrl: 'jxgz/veJwBzr/importExcel',
      },
      dictOptions: {},
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    initDictConfig() {},

    //回收站
    recycle: function () {
      this.$refs.recycle.show()
      this.$refs.recycle.title = '回收站'
      this.$refs.recycle.disableSubmit = false
    },

    //筛选
    filter: function () {
      console.log('1111')
      this.$refs.filter.edit()
      this.$refs.filter.title = '筛选'
      this.$refs.filter.disableSubmit = false
    },

    //接收所筛选条件
    filterFormOk(bjid, teacher, semid, createBy) {
      //this.jcid=id

      this.queryParam = {}
      if (bjid != null) {
        this.queryParam.bjid = bjid
      }
      if (teacher != null) {
        this.queryParam.teacher = teacher
      }
      if (semid != null) {
        this.queryParam.semid = semid
      }
      if (createBy != null) {
        this.queryParam.createBy = createBy
      }

      this.loadData()
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>